package glue

import (
	"fmt"
	"strings"
)

type Containers struct {
	Containers map[string]Container `json:"containers" yaml:"containers"`
}

type Container struct {
	//Name     string            `json:"name" yaml:"name"`
	ImageTag string            `json:"image_tag" yaml:"image_tag"`
	Runtime  string            `json:"runtime" yaml:"runtime"`
	Workdir  string            `json:"workdir" yaml:"workdir"`
	Cmds     []string          `json:"cmds" yaml:"cmds"`
	Envs     map[string]string `json:"envs" yaml:"envs"`
	Ports    map[string]string `json:"ports" yaml:"ports"`
	Mounts   map[string]string `json:"mounts" yaml:"mounts"`

	CpuSet   string `json:"cpu_set" yaml:"cpu_set"`
	Memory   string `json:"memory" yaml:"memory"`
	Cpu      string `json:"cpu" yaml:"cpu"`
	CpuShare string `json:"cpu_share" yaml:"cpu_share"`

	Service string `json:"application_service" yaml:"application_service"`

	ReportProxyServicPerfix string `json:"servic_perfix" yaml:"servic_perfix"`
	ReportEnable            bool   `json:"report_enable" yaml:"report_enable"`

	DependsOn      []string          `json:"depends_on" yaml:"depends_on"`
	ScheduleLabels map[string]string `json:"schedule_labels" yaml:"schedule_labels"`
}

func DeCodeScheduleLabels(labels string) map[string]string {
	ls := strings.Split(labels, ",")

	fmt.Printf("\n\n %v \n\n", ls)

	ms := make(map[string]string, len(ls))
	for _, v := range ls {
		kv := strings.Split(v, "=")
		ms[kv[0]] = kv[1]
	}
	return ms
}

//func EnCodeScheduleLabels(labels []string) string {
//	return strings.Join(labels, ",")
//}
